import request from '@/utils/request'

const activityApi = {
  // 活动列表
  getActivityList: (params) => {
    return request({
      url: '/promotion/activity/page',
      method: 'GET',
      params
    })
  },
  // 获取活动详情
  getActivityDetail: (activityId) => {
    return request({
      url: `/promotion/activity/get?id=${activityId}`,
      method: 'GET'
    })
  },
  // 商品范围校验
  checkGoodsRange: (data, hideErrorMessage) => {
    return request({
      url: '/promotion/activity/pre/valid',
      method: 'POST',
      hideErrorMessage,
      data
    })
  },
  // 新增活动
  addActivity: (data) => {
		return request({
			url: '/promotion/activity/create',
			method: 'POST',
      data
		})
	},
  // 更新活动
  updateActivity: (data) => {
		return request({
			url: '/promotion/activity/update',
			method: 'PUT',
      data
		})
	},
  // 删除活动
  deleteActivity: (activityId) => {
		return request({
			url: `/promotion/activity/delete?id=${activityId}`,
			method: 'DELETE'
		})
	},
  // 更新活动状态
  updateActivityStatus: (data) => {
		return request({
			url: '/promotion/activity/update/status',
			method: 'PUT',
      data
		})
	},
  // 更新活动商品
  updateActivityGoods: (data) => {
		return request({
			url: '/promotion/activity/update/spus',
			method: 'PUT',
      data
		})
	},
  // 获取活动统计数据
  getStatisticData: (supplierId) => {
    return request({
      url: `/promotion/activity/overview?supplierId=${supplierId}`,
      method: 'GET'
    })
  },
  // 获取活动订单统计数据
  getStatisticOrder: (supplierId) => {
    return request({
      url: `/trade/order/getActivityCount?supplierId=${supplierId}&type=1`,
      method: 'GET'
    })
  },
  // 已选商品列表
  getCheckedGoodsList: (activityId) => {
		return request({
			url: `/promotion/activity/list/selected/product?id=${activityId}`,
			method: 'GET'
		})
	},
  // 可选商品列表
  getCheckGoodsList: (supplierId) => {
		return request({
			url: `/promotion/activity/list/optional/product?supplierId=${supplierId}`,
			method: 'GET'
		})
	},
  // 供应商上架商品列表
  getReleaseGoodsList: (supplierId) => {
		return request({
			url: `/product/spu/page?pageNo=1&pageSize=-1&tabType=0&supplierId=${supplierId}`,
			method: 'GET'
		})
	},
}

export default activityApi
